
import React, { useEffect, useState,useContext } from "react";
import {  useNavigate } from 'react-router-dom'
import { Button, Space } from 'antd';
import type { MenuProps } from "antd";
import { setMenuList } from "@/redux/modules/menu/action";
import { connect,useDispatch,useSelector } from "react-redux";
import { Dispatch } from "redux";
const HomeButton = (props:any) => {
    const dispatch=useDispatch()
    console.log(props)
    const navigate = useNavigate();
    type MenuItem = Required<MenuProps>["items"][number];
    let  {menuList,setList} = props;
    const handleSetMenu = () => {
        menuList = [
            {
              title: '个人日程',
              path: '/home/schedule',
              key:0,
            },
            {
              title: '我的空闲时间段',
              path: '/home/schedule/free',
              key:1,
            },
            {
              title: '上月打卡记录',
              path: '/home/schedule/record',
              key:2,
            },
            {
              title: '我的参与课程',
              path: '/home/schedule/courses',
              key:3,
            },
            {
              title: '我的设置',
              path: '/home/schedule/setting',
              key:4,
            }
          ];
          setList(menuList)
          navigate("/home/schedule/free");
    }

    const handleSetMenu1 = () => {
      menuList = [
          {
            title: '日志周报',
            path: '/home/weekly',
            key:0,
          },
          {
            title: '我的日报',
            path: '/home/weekly/daily_paper',
            key:1,
          },
          {
            title: '我的周报',
            path: '/home/weekly/weekly_paper',
            key:2,
          },
        ];
        setList(menuList)
        navigate("/home/weekly/daily_paper");
  }
  const handleSetMenu2 = () => {
    menuList = [
        {
          title: '分享课表',
          path: '/home/share',
          key:0,
        },
        {
          title: '前端分享课程',
          path: '/home/share/front_sharing',
          key:1,
        },
        {
          title: '后端分享课程',
          path: '/home/share/back_sharing',
          key:2,
        },
        {
          title: '测试分享课程',
          path: '/home/share/test_sharing',
          key:3,
        },
        {
          title: '软技能分享课程',
          path: '/home/share/skill_sharing',
          key:4,
        },

      ];
      setList(menuList)
      navigate("/home/share/front_sharing");
}
const handleClick=()=>{
    navigate("/home/information");
}

    return (
        <div>
            <Space.Compact block>
                <Button type="dashed" onClick={handleSetMenu}>
                    个人日程
                </Button>
                <Button type="dashed" onClick={handleSetMenu1}>
                    日志周报
                </Button>
                <Button type="dashed" onClick={handleSetMenu2} >
                    分享课表
                </Button>
                <Button type="dashed" onClick={handleClick}>
                    我的统计信息
                </Button>
            </Space.Compact>
        </div>

    );
};
const mapStateToProps = (state: any) => state.menu;
const mapDispatchToProps = (dispatch:Dispatch)=>{
  return {
  setList: (menuList:any) => dispatch(setMenuList(menuList))
  }

};
export default connect(mapStateToProps, mapDispatchToProps)(HomeButton);